<?php
  function get_sub_brand_list($db,$product_class,$product_brand)
  {
   $result = array();
   $rs = $db->Execute("select * from SPIDER_PRODUCT_BRAND where product_class='".$product_class."' and product_brand='".$product_brand."'");
   foreach($rs->getRows() as $k => $v)
   {
// 	$r=$r."<option value=\"".$v['product_sub_brand']."\">".$v['product_sub_brand']."</option>";
	$result[$v['product_sub_brand']]= $v['id'];
   }
   return $result;

  }
  function get_brand_list($db,$product_class)
  {
    $result = Array();
    
    $rs = $db->Execute("select * from SPIDER_PRODUCT_BRAND where product_class='".$product_class."' group by product_class,product_brand");
    foreach($rs->getRows() as $k => $v)
    {
 	#$r=$r."<option  value=\"".$v['product_brand']."\">".$v['product_brand']."</option>";
        $result[] = $v['product_brand'];
        
    }
    return $result;
  }
  function get_product_class($db)
  {
    $result = Array();
    $rs = $db->Execute('select * from SPIDER_PRODUCT_BRAND  group by product_class');
    $r="<select  onchange=\"hints();\">";
    $k =0;
    $first = "";
    foreach($rs->getRows() as $k => $v)
    {
	$r=$r."<option value=\"".$v['product_class']."\">".$v['product_class']."</option>";
        if ($k==0){
	   $first = $v['product_class'];
           $k++;
	}
    }	
     
    $r  = $r."</select>";
    $result[] = $r;
    $result[] = $first;
    return $result;
  }
//  require('../action/db.php');
//  $brand_list 		= get_brand_list($db,"1");
//  $brand_sub_list 	= get_sub_brand_list($db,"1",$brand_list[0]);
  
//  echo json_encode(array("brand_list"=>$brand_list,"brand_sub_list"=>$brand_sub_list));
?>
